import {
	removeToken,
	removeUserInfo,
} from "@/service/localStorage.js";
// import {
// 	requestGet,
// 	requestPost,
// } from "@/service/request.js";
// import {
// 	xxxAPI,
// } from "@/service/api/common.js";

const user = {
	state: {
		// 用户数据
		userInfo: {
			name: "张三",
		},
		// 测试
		test: "测试",
	},
	mutations: {
		SET_USER_INFO: (state, userInfo) => {
			state.userInfo = userInfo;
		},
	},
	actions: {
		// 获取用户信息
		GetUserInfo({
			commit
		}) {
			return new Promise((resolve, reject) => {
				console.log("获取用户信息userInfo");
				// requestGet(xxxAPI, {
				// 	data: {}
				// }).then((res) => {
				// 	commit("SET_USER_INFO", res.data);
				// 	resolve(res);
				// }).catch((err) => {
				// 	reject(err);
				// });
			});
		},
		// 退出登录
		LogOut({
			commit
		}) {
			commit("SET_USER_INFO", {});
			removeCookies();
			removeUserInfo();
			// 重定向页面
			uni.navigateTo({
				url: "/pages/login/login"
			});
		},
		// 测试
		Test({
			commit
		}) {
			commit("SET_USER_INFO", {
				name: "测试"
			});
			console.log("正在调用store中的Test方法");
		}
	},
};

export default user;